<%@ page language="java" pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
	<%@include file="../include_new.jsp"%>
</head>
<body id="z_body">
<div id="app">
	<form class="form-horizontal" id="form_1">
		<input name="id" v-model="one.id" type="hidden"/>
		<div class="form-group">
			<label class="col-xs-3">应用名称</label>
			<div class="col-xs-7">
				<input class="form-control" name="mc" v-model="one.mc" validType="notEmpty">
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-3">应用代码</label>
			<div class="col-xs-7">
				<input class="form-control" v-if="act == 'add'" name="dm" validType="notEmpty">
				<input class="form-control" v-if="act == 'update'" v-model="one.dm" readonly="readonly">
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-3">描述</label>
			<div class="col-xs-7">
				<input class="form-control" name="ms" v-model="one.ms" validType="">
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-3">图标</label>
			<div class="col-xs-7">
				<input class="form-control" name="tb" v-model="one.tb" validType="" type="hidden">
				<i id="icon_tb" class="icon icon-2x" v-bind:class="'icon-'+one.tb"></i>
				&nbsp;
				<a class="btn" data-toggle='modal' data-size='lg' 
					data-iframe="../main/iconSelector">选择图标</a>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-3">地址</label>
			<div class="col-xs-7">
				<input class="form-control" name="dz" v-model="one.dz" validType="">
				<span class="app_formTip">非web应用的地址设置为空</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-3"></label>
			<div class="col-xs-7">
				<a class="btn btn-primary" onclick="save()">保存</a> &nbsp;
				<a class="btn btn-default" href="javascript:;" onclick="parent.closeModal()">取消</a>
			</div>
		</div>
	</form>
</div>
	
<script type="text/javascript">
	var act = "${act}", id = "${id}";
	
	var vm = new Vue({
		el: "#app",
		data: {
			act: act,
			one: {}
		}
	});
	
	if(act == "update") {
		tool.query("../app/load4Update", {id: id}, function(data) {//提交
			vm.one = data;
		});
	}

	//保存
	function save() {
		if(validateForm("form_1")) {//表单验证
			tool.save("../app/"+act, $("#form_1").serialize(), function(data) {//提交
				parent.getPage();
				setTimeout(function(){
					parent.closeModal();
				}, 800);
			});
		}
	}
	
	//回调-选择图标
	function onChooseIcon(val) {
		closeModal();
		$("#form_1 [name='tb']").val(val);
		$("#icon_tb").attr("class", "icon icon-2x icon-"+val);
	}
	
</script>
<style type="text/css">
	#z_body{min-height:500px;}
</style>
</body>
</html>